package io.renren.modules.app.controller;

import io.renren.common.utils.R;
import io.renren.modules.app.interceptor.AuthorizationInterceptor;
import io.renren.modules.app.utils.JwtUtils;
import io.renren.modules.bs.service.BsDepartmentAdministratorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/app/admin")
@Api(value = "管理员控制器",tags="管理员控制器")
public class AppUserController {

    @Autowired
    private JwtUtils jwtUtils;

    @Autowired
    private BsDepartmentAdministratorService administratorService;

    @PostMapping("updatePwd")
    @ApiOperation("更新密码")
    public R updatePwd(HttpServletRequest request,String newPwd){

        Long adminId = (Long) request.getAttribute(AuthorizationInterceptor.USER_KEY);
        this.administratorService.updatePwd(newPwd,adminId);
        return R.ok();
    }
}
